package com.sanctuary.tools;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.sanctuary.dao.interfaces.TermDao;
import com.sanctuary.models.Term;

/**
 * Create/re-fresh the solr/lucene index with terms in our database
 * 
 * @author dpalmer
 *
 */
public class Indexer {
	private static final Log LOG = LogFactory.getLog(Indexer.class);
	/**
	 * Main - start up this program
	 * @param args
	 */
	public static void main(String[] args) throws Exception {

		TermDao dao = (TermDao) BaseTool.IOC_ENGINE.getBean("termDao");
		List<Term> terms = dao.findAll();

		for (Term term : terms) {
			try {
				SolrTools.addModel(term);
			} catch (Exception ex) {
				LOG.error(StringTools.getStackTrace(ex));
			}
		}	
	}
}
